<template>
<!-- 全部在内部写 只能有一个根元素 -->
  <div id="app">
    <div class="first">
    <!-- 头部 -->
    <div class="top">
      <div class="sign">
        <!-- 上 -->
      <img src="./assets/logo1.gif" alt="">
      <div class="sign-right">
         <i class="iconfont icon-sandianheng"></i>
       <i class="iconfont icon-cuohao"></i>
      </div>
      <!-- 头-下 -->
      </div>
      <div class="ss" >
        <div class="nei">
        <i class="iconfont icon-sousuo"></i>
        <p>输入商家、商品名称</p>
        </div>
      </div>
    </div>
    <!-- 轮播图 -->
    <div class="pic">

    </div>
    <!-- 主体 -->
    <div class="mian">
      <h2>猜你喜欢</h2>
      <!-- 选择 -->
      <div class="opes">
        <span>综合排序<i class="iconfont icon-xia"></i></span>
        <span @click="distClick">距离最近</span>
        <span @click="handleClick">销量最高</span>
        <span>筛选<i class="iconfont icon-shaixuan-"></i></span>
      </div>
      <div class="list">
      <div class="shop" v-for="(item,index) in list" :key="index">
        <img :src="item.img" alt="item.name" :title="item.name">
        <div class="text">
          <h3>{{ item.name }}</h3>
          <p>月售: {{ item.saled }}</p>
          <p> <span>  起送 ¥ {{ item.start }} 远距离配送¥ {{item.send}}</span> <span>距离{{item.km}}km</span></p>
          <p>扬州炒饭棒棒哒!</p>
        </div>
      </div>
      <div class="loading" v-if="list.length == 0">
        正在拼命加载中...
      </div>
    </div>
    </div>
    <!-- 固定底部 -->
<div class="footer"><i class="iconfont icon-elema1"><br>首页</i><i class="iconfont icon-dingdan"><br>订单</i><i class="iconfont icon-wode"><br>我的</i></div>
  </div>
  
  </div>
</template>

<script>

export default {
    data:()=>{
    return {
      list:[
        {
          "id":0,
          "name":"金百万烤鸭(苏家坨店)",
          "img":"https://img1.baidu.com/it/u=1124520378,3095507368&fm=26&fmt=auto",
          "saled":200,
          "start":20,
          "send":3,
          "km":"4.2"
        },
        {
          "id":1,
          "name":"李家烤馍",
          "img":"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fimg.jj20.com%2Fup%2Fallimg%2Ftp01%2F1ZZQ20QJS6-0-lp.jpg&refer=http%3A%2F%2Fimg.jj20.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641430682&t=51a01b2e54bcb97ad2eac8fb9324aca7",
          "saled":100,
          "start":30,
          "send":3,
          "km":"3.2"
        },
        {
          "id":2,
          "name":"武汉热干面",
          "img":"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic9.nipic.com%2F20100914%2F2531170_171928949919_2.jpg&refer=http%3A%2F%2Fpic9.nipic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641430794&t=c64edc94459f7fb41d0093479f5768d6",
          "saled":300,
          "start":10,
          "send":3,
          "km":"5.9"
        },
        {
          "id":3,
          "name":"炸鸡",
          "img":"https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fc-ssl.duitang.com%2Fuploads%2Fblog%2F201403%2F29%2F20140329145413_hw4HA.thumb.1000_0.jpeg&refer=http%3A%2F%2Fc-ssl.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1641430823&t=04b2868396898e454e8e4d8b34f26817",
          "saled":400,
          "start":100,
          "send":5,
          "km":"2.1"
        }
      ],
      listh:['黄焖鸡','汉堡','水饺','海底捞','热干面'],
      listj:['烧饼','牛肉盖饭','刀削面','海底捞','热干面'],
    }
  },

  /* methods 负责定义函数, 一个页面只能有一个methods,多个函数写在methods内部 用逗号分隔 */
  methods:{
    handleClick(){
      //this 代表当前组件实例
      //this.list 获取data中定义的数据
      //this.$data.list  获取data中定义的数据
      this.list.sort((a,b)=>{
        return b.saled - a.saled;
      })
    },
    // 距离最近
    distClick(){
      this.list.sort((a,b) =>{
        return a.km - b.km;
      }

      )
    },
   
    // 点击清空
    qingkong(){
      this.listh = [];
    }
  },
  name: 'App',
  components: {
  }
}
</script>

<style>


*{
  margin: 0;
  padding: 0;
}
 #app{
       /* background-color: aqua;   */
       width: 100%; 
       /* height: 700px; */
        }
 /* 头部 */
.top{
  width: 100%;
  height: 120px;
  background: linear-gradient(#00a4ff,#008fff);
}
.sign{
  display: flex;
  justify-content: space-between;
  align-content: center;
  padding-top: 10px;
}
.sign img{
  margin-left: 30px;
}
.sign-right{
  width: 100px;
  height: 40px;
  border: 1px solid grey;
  margin-right: 10px;
  border-radius: 20px;
  background-color: #0076d9;
  display: flex;
}
.sign-right i{
  text-align: center;
  margin:5px 0;
  font-size: 26px;
  line-height: 30px;
  color:white;
  width: 50px;
  height: 30px;
  /* border: 1px solid black; */

}
.sign-right i:first-child{
  border-right: 1px solid #1a83dc;
  text-align: center;

}

.ss {
  width: 80%;
  height: 45px;
  background-color:#f5fbff;
  margin: 10px auto;
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}
.nei{
  width: 200px;
  height:35px ;
  display: flex;
  color: #c3c9cd;
}
.nei i{
  margin-right: 5px;
  font-size: 25px;
  line-height: 35px;
  text-align: center;
}
.nei p{
  text-align: center;
  font-size: 15px;
  font-style: normal;
  line-height: 35px;
}
/* 轮播图 */
.pic{
  width: 90%;
  height: 120px;
  margin: 20px auto;
  background-color: khaki;
  border-radius: 5px;
}
/* 主体 */
.mian h2{
  margin:15px;
  font-size: 22px;

}
/* 选择 */
.opes{
  display: flex;
  justify-content: space-between;
  align-content: center;
  margin: 15px;
  cursor: pointer;
}
.list{
  margin-bottom: 10px;
}
.list .shop{
  display: flex;
  margin: 15px;
}
.list .shop img{
  width: 120px;
  height: 100px;
  margin-right: 10px;
}
.text p:nth-child(3){
  font-size: 12px;
  padding-top: 5px;

}
.text p:nth-child(4){
  padding-top: 15px;
  /* font-size: 24px; */
}
.text p span:nth-child(1){
  float: left;
  margin-right: 5px;
}
.text p span:nth-child(2){
  float: right;
  /* margin-right: 5px; */
}
.footer{
  width: 100%;
  height: 50px;
  background-color: white;
  border-top: 1px solid grey;
  position: fixed;
  bottom: 0;
  right: 0;
}
.footer i{
  display: block;
  float: left;
  width: 33.2%;
  height: 50px;
  /* background-color: rosybrown; */
  line-height: 20px;
 font-size:16px;
 padding-top: 5px;
  text-align: center;
  color: grey;
}
.footer i:hover{
  color: #008eff;
}
.footer i .iconfont{
  margin-bottom: 5px;
font-size:30px;
}
.loading{
  text-align: center;
  padding: 100px 0;
}

/* 第二部分 */

</style>
